package agents.interaction;

import game.constants.ReferenceAgent;
import game.constants.ReferenceObject;
import game.constants.ReferenceSpecialFeature;
import interfaces.impl.HumanInteraction;

import java.util.ArrayList;

import objects.SpetialFeature;
import objects.WorldObject;
import universe.Universe;
import actions.ActionCreateStarcraftObject;

public class InteractionCreateFireBat extends HumanInteraction {
	
ActionCreateStarcraftObject actionCreateStarcraftObject;
	
	SpetialFeature firebatPrice;
	SpetialFeature firebatVespeneGas;

	@Override
	public void initializeParametersList() {
		
		
	}

	@Override
	public void initializeActionList() {

		actionCreateStarcraftObject=new ActionCreateStarcraftObject();
		addAction(actionCreateStarcraftObject);
	}

	@Override
	public void initializeSpecialFeatures() {

		firebatPrice= new SpetialFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_FIRE_BAT_PRICE);
		addSpetialFeature(firebatPrice);
		
		firebatVespeneGas = new SpetialFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_FIRE_BAT_VESPENE_GAS);
		addSpetialFeature(firebatVespeneGas);
		
	}

	@Override
	public void initializeName() {
		name="Build FIREBAT";
		
	}

	@Override
	public void initializeId() {
		id=ReferenceAgent.AGENT_HUMAN_INTERACTION_BUILD_FIRE_BAT;
		
	}

	@Override
	public void updateChild(WorldObject object, Universe universe, double time) {
		
		ArrayList<WorldObject> academyList = universe.getListObjects(ReferenceObject.OBJECT_REFERENCE_ACADEMY1);
		for(WorldObject academy : academyList){
			
			if(academy.getOwner()==object.getOwner()){

				actionCreateStarcraftObject.setSource(object);
				actionCreateStarcraftObject.setTarget(object);
				actionCreateStarcraftObject.setObjectReference(ReferenceObject.OBJECT_REFERENCE_FIREBAT1);
				actionCreateStarcraftObject.setPrice(firebatPrice.getValue());
				actionCreateStarcraftObject.setVespeneGas(firebatVespeneGas.getValue());
				universe.setAction(actionCreateStarcraftObject);
				isActive=false;
				return;
			}
			
		}
		universe.generateDialogMessage(object.getOwner(), "NECESITO ALGUNA ACADEMY");
		isActive=false;
		
	}
	


}
